/**
 * Apr 11, 2010
 */
package org.tomale.id.gis.ui.internal;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;

/**
 * @author ferd
 *
 */
public class GLColor {

	private float _red;
	private float _blue;
	private float _green;
	
	private final int MAX_COLOR_VAL = 255;
	
	public GLColor(final Color color){
		_red = color.getRed()/MAX_COLOR_VAL;
		_blue = color.getBlue()/MAX_COLOR_VAL;
		_green = color.getGreen()/MAX_COLOR_VAL;
	}
	
	public GLColor(final float red, final float blue, final float green){
		_red = red;
		_blue = blue;
		_green = green;
	}
	
	
	public float getRed(){
		return _red;
	}
	
	public float getBlue(){
		return _blue;
	}
	
	public float getGreen(){
		return _green;
	}
	
	public Color getColor(final Device device){
		return new Color(device, (int) _red*MAX_COLOR_VAL,(int) _blue*MAX_COLOR_VAL,(int) _green*MAX_COLOR_VAL);
	}
	
	public static GLColor toGLColor(final Color color){
		return new GLColor(color);
	}
}
